package com.cf.vo;

import com.github.pagehelper.PageInfo;

/**
 * boot-common-Page
 *
 * @author <a href="2428922347@qq.com">Zhu mingming</a>
 * @info
 * @since 2018/9/10 下午 02:09
 */
public class Page<Data> {

    private int page;

    private int size;

    private boolean left;

    private boolean previous;

    private Data data;


    public static Page toPage(PageInfo pageInfo) {
        return toPage(pageInfo, pageInfo.getList());
    }

    public static Page toPage(PageInfo pageInfo, Object data) {
        Page page = new Page();
        page.setData(data);
        page.setLeft(pageInfo.isHasNextPage());
        page.setPrevious(pageInfo.isHasPreviousPage());
        page.setPage(pageInfo.getPageNum());
        page.setSize(pageInfo.getPageSize());
        return page;
    }

    public int getPage() {
        return page;
    }

    public Page<Data> setPage(int page) {
        this.page = page;
        return this;
    }

    public int getSize() {
        return size;
    }

    public Page<Data> setSize(int size) {
        this.size = size;
        return this;
    }

    public boolean isLeft() {
        return left;
    }

    public Page<Data> setLeft(boolean left) {
        this.left = left;
        return this;
    }

    public boolean isPrevious() {
        return previous;
    }

    public Page<Data> setPrevious(boolean previous) {
        this.previous = previous;
        return this;
    }

    public Data getData() {
        return data;
    }

    public Page<Data> setData(Data data) {
        this.data = data;
        return this;
    }
}
